from fastapi import Request, status
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse


async def validationExceptionHandler(request: Request, exc: RequestValidationError):
    """自定义参数验证异常错误"""
    errMsg = ""
    for error in exc.errors():
        errMsg += ".".join(error.get("loc")) + ":" + error.get("msg") + ";"
    return JSONResponse(status_code=status.HTTP_200_OK, content={"code": 400, "message": errMsg})
